package huoye.shops.huoye.operation.adapter;

import android.content.Context;
import android.graphics.Paint;
import android.util.Log;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.codeideology.android.widget.recycler.RecyclerViewAdapter;

import java.math.BigDecimal;

import butterknife.BindView;
import huoye.shops.R;
import huoye.shops.base.APIUrls;
import huoye.shops.huoye.operation.model.SellOrder;
import huoye.shops.huoye.operation.model.ShopPrizeList;
import huoye.shops.utils.StockUtils;
import huoye.shops.widget.RoundImageView;

import static huoye.shops.huoye.operation.activity.ManagePrizeActivity.EXTRAS_KEY_PRIZE_SELECT;


/**
 * Created by uesr on 2018/8/10.
 */

public class ManageShopPrizeAdapter extends RecyclerViewAdapter<ManageShopPrizeAdapter.ViewHolder,ShopPrizeList> {


    String mType = "";
    public ManageShopPrizeAdapter(Context context, String type) {
        super(context, R.layout.item_manage_shop);
        this.mType = type;
    }

    @Override
    protected ViewHolder initViewHolder(View view, int i) {

        return new ViewHolder(view);
    }

    private SellOrder mSellOrder;
    @Override
    protected void bindView(ViewHolder holder, ShopPrizeList shopPrizeList, int i) {

            //奖品管理
            if(getContext() != null){
                Glide.with(getContext())
                        .load(APIUrls.COMMON_CONFIG.TYPE_COMMON_ALIYUN+shopPrizeList.getPrizeImg())
                        .dontAnimate()
                        .placeholder(R.mipmap.ic_wait_logo)
                        .error(R.mipmap.ic_error)
                        .into(holder.rvShop);
            }
        Log.e("test",APIUrls.COMMON_CONFIG.TYPE_COMMON_ALIYUN+shopPrizeList.getPrizeImg());

            holder.tvName.setText(shopPrizeList.getPrizeTitle());
            String moenyNum = StockUtils.moenyStyle(shopPrizeList.getPrizeSale());

        holder.tvMoneyDiscount.setText("￥"+moenyNum + "");
        holder.tvMoneyOriginal.setText(moenyNum + "");
        ////中间横线
        holder.tvMoneyOriginal.getPaint().setFlags(Paint.STRIKE_THRU_TEXT_FLAG);
        // 抗锯齿
        holder.tvMoneyOriginal.getPaint().setAntiAlias(true);

            holder.tvNum.setText("库存"+shopPrizeList.getPrizeNum());
            if(shopPrizeList.getiState() == 0){
                holder.tvStare.setVisibility(View.VISIBLE);
                holder.tvStare.setText("审核中");
            }else {
                holder.tvStare.setVisibility(View.GONE);
            }







       // 状态（-1：已删除 0：待审核 1：审核通过 2：审核失败）
      /*  switch (shopPrizeList.getiState()){
            case 0:
                holder.tvStare.setText("待审核");
                break;
            case 3:
            case 5:
                holder.tvStare.setText("处理中");
                break;
            case 4:
                holder.tvStare.setText("已完成");
               // holder.tvStare.setTextColor(Color.parseColor("#9B9B9B"));
                break;

        }*/



    }


    public class ViewHolder extends RecyclerViewAdapter.ViewHolder {

        @BindView(R.id.item_manage_shop_ll)
        LinearLayout ll;

        @BindView(R.id.item_manage_shop_tv_shop_name)
        TextView tvName;
        @BindView(R.id.item_manage_shop_tv_state)
        TextView tvStare;
        @BindView(R.id.item_manage_shop_tv_money_discount)
        TextView tvMoneyDiscount;
        @BindView(R.id.item_manage_shop_tv_money_original)
        TextView tvMoneyOriginal;

        @BindView(R.id.item_manage_shop_tv_num)
        TextView tvNum;


        @BindView(R.id.item_manage_shop_rv_shop)
        RoundImageView rvShop ;


        public ViewHolder(View itemView) {
            super(itemView);
        }
    }



}
